package com.lzp.aop.controller;

import com.lzp.aop.service.AopTryCallOtherInterface;
import com.lzp.aop.service.TestService;
import com.lzp.aop.strategy.ServiceEnum;
import com.lzp.aop.strategy.StrategyContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : lzp
 * @version 1.0
 * @date : 2022/8/25 14:56
 * @apiNote : TODO
 */
@RestController
public class TestController {
    @Autowired
    StrategyContext strategyContext;
    @Autowired
    AopTryCallOtherInterface aopTryCallOtherInterface;

    @RequestMapping("/aop/testMethod/{type}/{str}")
    public String testMethod(@PathVariable Integer type,@PathVariable String str) {
        return StrategyContext.getTestServiceConcurrentHashMap(type).testMethod(str);
    }

    @RequestMapping("/aop/testMethodThrow1/{type}/{str}")
    public String testMethodThrow(@PathVariable Integer type,@PathVariable String str) {
        return StrategyContext.getTestServiceConcurrentHashMap(type).testMethodThrow(str);
    }

    @RequestMapping("/aop/testMethodThrow2/{type}/{str}")
    public String testMethodThrow2(@PathVariable Integer type,@PathVariable String str) {
        return StrategyContext.getTestServiceConcurrentHashMap(type).testMethodThrow2(str);
    }
    @RequestMapping("/aop/call/testMethod/{type}")
    public String call(@PathVariable Integer type) {
        return aopTryCallOtherInterface.testMethod(StrategyContext.getTestServiceConcurrentHashMap(type));
    }
    @RequestMapping("/aop/call/callOne/{str}")
    public String call(@PathVariable String str) {
        return aopTryCallOtherInterface.callOne(str);
    }
}
